package thread_pool;

import java.util.HashMap;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/5/23
 * Time:16:31
 * 缺点：不可继承性
 **/
public class PoolDemo30 {

    static ThreadLocal<String> threadLocal = new ThreadLocal<>();


    public static void main(String[] args) {
        /*threadLocal.get();

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                HashMap<String,String> map = new HashMap<>();

            }
        });*/

        //set threadLocal
        threadLocal.set("java");

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                //get threadLocal
                String result = threadLocal.get();
                System.out.println("结果"+result);
            }
        });
        t1.start();

    }
}
